"use strict";
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
//  ts的类
var Person = /** @class */ (function () {
    function Person(name, age, sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
    }
    Person.prototype.getName = function () {
        return this.name;
    };
    Person.prototype.setName = function (name) {
        this.name = name;
    };
    Person.prototype.getAge = function () {
        return this.age;
    };
    Person.prototype.setAge = function (age) {
        this.age = age;
    };
    Person.prototype.getSex = function () {
        return this.sex;
    };
    Person.prototype.setSex = function (sex) {
        this.sex = sex;
    };
    Person.prototype.run = function () {
        return this.name + "\u5728\u8FD0\u52A8";
    };
    //  静态方法
    Person.print = function () {
        //  静态方法不能访问类的变量
        //console.log(this.name)
        return Person.num;
    };
    Person.num = '20'; //  静态属性
    return Person;
}());
var p = new Person('ywj', 21, '男');
console.log(p.getName());
console.log(p.run());
//  ts的继承
var Web = /** @class */ (function (_super) {
    __extends(Web, _super);
    function Web(name, age, sex) {
        return _super.call(this, name, age, sex) || this;
    }
    Web.prototype.run = function () {
        //  public和protected可以在子类里被访问
        //  private不可以在子类里被访问
        return this.name + "\u5728\u8FD0\u52A8---\u5B50\u7C7B" + this.age + "---";
    };
    return Web;
}(Person));
var w = new Web('YWJ', 18, '男');
//  子类和父类有相同的方法 优先执行子类的方法
console.log(w.run());
//  public可以在外部访问
console.log(w.name);
//  protected无法在外部访问
// console.log(w.age)
//  private无法在外部访问
// console.log(w.sex)
console.log(Person.print());
//  多态 父类定义方法 子类实现
//  抽象方法 抽象类
//  抽象类中可以含有抽象方法 也可以有实例方法
var Animal = /** @class */ (function () {
    function Animal(name) {
        this.name = name;
    }
    Animal.prototype.play = function () {
        console.log(this.name + '在玩耍');
    };
    return Animal;
}());
//  继承抽象方法的子类 必须实现父类抽象类中的抽象方法
var Dog = /** @class */ (function (_super) {
    __extends(Dog, _super);
    function Dog(name) {
        return _super.call(this, name) || this;
    }
    Dog.prototype.eat = function () {
        return this.name + "\u5728\u5403";
    };
    Dog.prototype.run = function () {
        return this.name + "\u5728\u8DD1";
    };
    return Dog;
}(Animal));
var dog = new Dog('ywj');
console.log(dog.eat());
console.log(dog.run());
dog.play();
